package com.jyw.business.obstacles.wechat.controller;

import com.jyw.business.obstacles.domain.dto.wechat.WxWorkOrderQueryPageDto;
import com.jyw.business.obstacles.domain.vo.wechat.WxWorkOrderQueryInfoVO;
import com.jyw.business.obstacles.domain.vo.wechat.WxWorkOrderQueryPageVO;
import com.jyw.business.obstacles.service.IObsOrderFaultService;
import com.jyw.business.obstacles.service.IObsOrderInfoService;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Created by ZhangCheng on 2023/09/06 （微信工单查询）
 */
@RestController
@RequestMapping("/wechat/workOrderQuery")
@Api(tags = "微信工单查询")
public class ObsWxWorkOrderQueryController extends BaseController {

    @Resource
    private IObsOrderFaultService obsOrderFaultService;

    @Resource
    private IObsOrderInfoService obsOrderInfoService;

    /**
     * 微信分页查询所有工单
     *
     * @param wxWorkOrderQueryPageDto
     * @return
     */
    @PostMapping("/pageList")
    @ApiOperation("微信分页查询所有工单")
    public TableDataInfo<WxWorkOrderQueryPageVO> pageList(@RequestBody WxWorkOrderQueryPageDto wxWorkOrderQueryPageDto) {
        startPage();
        wxWorkOrderQueryPageDto.setUserId(getUserId());
        List<WxWorkOrderQueryPageVO> list = obsOrderFaultService.pageWxAllWorkOrder(wxWorkOrderQueryPageDto);
        return getDataTable(list);
    }

    /**
     * 微信通过工单号查询工单详情
     *
     * @param orderNum
     * @return
     */
    @GetMapping("/getInfoByOrderNum")
    @ApiOperation("微信通过工单号查询工单详情")
    public CommonResult<WxWorkOrderQueryInfoVO> getInfoByOrderNum(String orderNum) {
        return CommonResult.success(obsOrderInfoService.getDetailByOrderNum(orderNum));
    }
}
